import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        count: 0,
        name: 'lj',
        age: '18',
    },
    getters: { // 计算属性
        getInfo: (state)=> {
            return `this is a handsome boy that called ${state.name}`
        },
        getAge: (state) => {
            return `the boy is ${state.age} years old`
        }
    },
    mutations: {
        increment(state) {
            state.count++
        },
        changeName(state) {
            if (state.name === 'lj') {
                state.name = 'lf'
            } else {
                state.name = 'lj'
            }
        }
    }
})

export default store